home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
CRS
/
crs21.d81
/
hiressrl.sfx
/
hiscroll.ebud
< prev
Wrap
Text File
|
1990-02-12
|
8KB
|
343 lines
; "HIRES SCROLL" IS A DEMONSTRATION PROGRAM
; TO SHOW HOW TO SMOOTH SCROLL A HIRES
; BITMAP SCREEN.
;
; ┬Y ╩OHN ╠EESON, ┴UGUST 19, 1990
; ╤-╠INK ╨ROGRAMMERS' ╫ORKSHOP
;
; ┴ HIRES BITMAP SCREEN SHOULD BE LOADED
; AT $6000 BEFORE ENTERING THIS ROUTINE.
; ╘HE COLOR ARRAY SHOULD BE AT $5C00 FOR
; THIS SCREEN. $8800 IS USED FOR THE
; ALTERNATE SCREEN COLOR ARRAY, AND
; $A000 IS USED FOR THE ALTERNATE BITMAP.
; ╘HE COLOR ARRAY IS MOVED TO $4800 SO
; THAT THE ╓╔├ CHIP CAN SEE IT IN BANK 2.
; ╘HIS IS THE CORRECT SETUP FOR ─OODLE
; (DD FILES) GRAPHICS.
;
.ORG $C000
.MEM
;.DIS
.DVO 10
;.OBJ "HISCROLL.C000"
; SOURCE IS HIRES SCROLL.SRC
;
; ** ZERO PAGE WORK AREA **
;
SAPTR = $FB ;POINTER TO SCREEN A
SBPTR = $FD ;POINTER TO SCREEN B
LCOLA = $19 ;LEFT COL SCREEN A PTR
;
; ** SYSTEM POINTERS **
;
IRQVEC = $314 ;╔╥╤ VECTOR
;
; ** ASSEMBLER CONSTANTS **
;
VB2 = %01 ;╓╔├ CHIP VIDEO BANK BITS
VB1 = %10 ; FOR BANK 2 AND BANK 1
BMADR = $28 ;$0800 COLOR, $2000 BITMAP
BMMODE = $20 ;ENABLE BIT MAP IN YCR
DEBUG = 0 ;CONDITIONAL ASSY FLAG
SCRCNT = 5 ;SCROLL COUNTER. ├AN BE AS
; LOW AS 2, NO LOWER.
VICXCRDATA = $07 ;MAKE $0F FOR 40 COL SCREEN
;
; ** ╔/╧ REGISTERS
;
CIA2DRA = $DD00 ;VIDEO BANK BITS 0-1
VICMCR = $D018 ;VIC MEMORY CTRL REG
VICYCR = $D011 ;VIC CTRL REG Y
VICRCR = $D012 ;VIC RASTER CMP REG
VICXCR = $D016 ;VIC CTRL REG X
CIA1ICR = $DC0D ;CIA 1 INT CTRL REG
VICIFR = $D019 ;VIC INT FLAG REG
VICIMR = $D01A ;VIC INT MASK REG
CPUIO = $01 ;PROCESSOR I/O
;
START = * ;SETUP ╔╥╤
SEI
LDA IRQVEC:STA OLDIRQ
LDA IRQVEC+1:STA OLDIRQ+1
LDA #<NEWIRQ:STA IRQVEC
LDA #>NEWIRQ:STA IRQVEC+1
; SETUP FOR RASTER ╔╥╤ ON LINE 250
LDA #$7F:STA CIA1ICR ;DISABLE CIA ╔╥╤
LDA CIA1ICR ;RESET PENDING
LDA VICYCR:AND #$7F:STA VICYCR ;RASTER HIBIT
LDA #$FA:STA VICRCR ;RASTER CMP LINE 250
LDA #$01:STA VICIMR ;ENABLE RASTER IRQ
LDA VICIFR:STA VICIFR ;RESET PENDING
; SETUP FOR INITIAL BITMAP DISPLAY SCREEN A
LDA VICYCR:ORA #BMMODE:STA VICYCR
LDA #BMADR:STA VICMCR
;
POKEPLACE = *+1
LDA #SCRCNT:STA COUNTER ;SETUP TIME DELAY
STA COUNTGONE+1 ;SELF MODIFYING CODE
;
LDA #$00 ;SETUP SCREEN VARS
STA SCREENA:STA SCREENB
STA SAPTR:STA SBPTR
LDA #$60:STA SCREENA+1
LDA #$A0:STA SCREENB+1
LDA #VB1:STA VBANKA
LDA #VB2:STA VBANKB
; START WITH SCREEN A
LDA CIA2DRA:AND #$FC:ORA VBANKA:STA CIA2DRA
;
LDA #$5C:STA SAPTR+1 ;DOODLE COLOR LOCATION
LDA #$48:STA SBPTR+1 ;WHERE WE WANT IT
LDX #25 ;COUNTERS
- LDY #0
- LDA (SAPTR),Y
STA (SBPTR),Y
INY:CPY #40:BNE - ;MOVE COLOR ARRAY
DEX:BEQ +
JSR ADD40
CLC:BCC --
;
+ LDA CPUIO:AND #$FE:STA CPUIO
JSR MOVE2B ;MOVES A TO B WITH SHIFT
LDA CPUIO:ORA #$01:STA CPUIO
;
CLI ;KICK IT OFF
RTS
;
; ** LOCAL VARIABLES **
;
OLDIRQ .WORD 0 ;SAVED ╔╥╤
SCREENA .WORD $6000 ;$2000 IN VID BNK 1
SCREENB .WORD $A000 ;$2000 IN VID BNK 2
VBANKA .BYTE VB1 ;BANK FOR SCRN A
VBANKB .BYTE VB2 ;BANK FOR SCRN B
COUNTER .BYTE SCRCNT ;DELAY COUNTER FOR SCROLL
WORK .BYTE 0,0 ;DEBUG COUNTERS
;
NEWIRQ = * ;ENTER HERE WITH ╔╥╤
LDA VICIFR:STA VICIFR ;RESET PENDING
;
; ╘EST CODE:
.IF DEBUG
INC WORK ;INCREMENT ╔╥╤ COUNTER
.IFE
;
DEC COUNTER
BEQ COUNTGONE ;SCROLL IF TIME GONE
JMP (OLDIRQ) ;ELSE EXIT
;
COUNTGONE = *
LDA #SCRCNT ;RESET COUNTER
STA COUNTER
LDA VICXCR ;GET CURRENT SCROLL POSITION
AND #$07
BEQ MOVESCREEN ;IF SCROLL IS AT 0
DEC VICXCR ;ELSE SCROLL AND EXIT
JMP (OLDIRQ)
;
; ╚ERE IT IS TIME TO SWAP SCREENS, RESET
; THE SCROLL POSITION TO 7, THEN START
; MOVING THE SCREEN LEFT 8 BITS.
;
MOVESCREEN = *
; ** TEST CODE **
.IF DEBUG
STA WORK ;RESET ╔╥╤ COUNTER (.┴ = 0)
.IFE
; ** END TEST CODE **
LDA CPUIO ;BANK ┬┴╙╔├ ╥╧═ OUT
AND #$FE
STA CPUIO
LDA CIA2DRA
AND #$FC
ORA VBANKB ;SHOW SCRN B
; ╘HE VALUE IN VBANKB TOGGLES BETWEEN
; SCREEN 1 AND SCREEN 2, SO THIS TOGGLES
; BETWEEN THE TWO SCREENS.
STA CIA2DRA
LDA #VICXCRDATA
STA VICXCR ;SCROLL POS TO 7
CLI ;!?
;
; ╞ROM THIS POINT ON ANOTHER ╔╥╤ CAN
; OCCUR. ╔F IT DOES, THEN THE TOP PART
; OF THIS ROUTINE WILL EXECUTE AGAIN
; WHILE THE FOLLOWING PART IS STILL
; EXECUTING. ╘HE TOP PART WILL EXECUTE
; 8 TIMES COUNTER TIMES BEFORE IT FALLS
; INTO THE MOVE SCREEN PART, HOWEVER, SO
; THE FOLLOWING HAS ABOUT 1.1 SECOND TO
; FINISH MOVING THE SCREEN BITMAPS
; AROUND, WITH THE DEFAULT COUNTER OF 5
;
; ╞IRST, SWAP THE SCREEN POINTERS SO
; THAT SCREEN A AND SCREEN B ARE REVERSED.
;
JSR SWAPSCREENS
;
; ╘HEN MOVE SCREEN DATA TO SCREEN B
; SHIFTED LEFT 8 BITS
;
JSR MOVE2B
;
; ╥ESTORE ┬┴╙╔├ ╥╧═
; AND EXIT THROUGH THE OLDIRQ.
;
IRQOUT = *
LDA CPUIO:ORA #$01:STA CPUIO
JMP (OLDIRQ)
;
; ** ┴LL DONE **
;
SWAPSCREENS = * ;EXCHANGES POINTERS
; FIRST THE BANK PTRS
LDA VBANKA:LDX VBANKB
STX VBANKA:STA VBANKB
; THEN THE SCREEN PNTRS
LDA SCREENA:LDX SCREENB
STX SCREENA:STA SCREENB
LDA SCREENA+1:LDX SCREENB+1
STX SCREENA+1:STA SCREENB+1
RTS
;
; ** ╠OCAL VARIABLES FOR MOVE **
;
ROWCOUNT .BYTE 0
;
MOVE2B = * ;MOVES SCREEN A TO B
; WITH A SHIFT LEFT BY 8 BITS
; ╬OTE: THIS ROUTINE ╫╔╠╠ BE INTERRUPTED
; BY ANOTHER RASTER ╔╥╤. ┬UT IT IS
; NOT AFFECTING THE SCREEN THAT IS
; CURRENTLY BEING DISPLAYED, SO THAT
; IS OKAY. ╔T MUST ╬╧╘, HOWEVER,
; AFFECT ANY POINTERS BEING USED TO
; DISPLAY SCREENS. ╔F IT IS POSSIBLE
; TO TAKE TOO LONG IN HERE THEN A
; FLAG WOULD HAVE TO BE USED IN THE TOP
; PART OF THE ╔╥╤ TO PREVENT RE-ENTRY
; INTO THIS CODE WHILE IT IS RUNNING.
; ** SETUP POINTERS AND COUNTERS **
; ╞IRST SAVE ┬┴╙╔├ ┌╨ WORK AREA WE NEED
LDA LCOLA+1:PHA:LDA LCOLA:PHA
CLC ;SAPTR TO ONE COL RIGHT OF SBPTR
LDA SCREENA:STA LCOLA:ADC #8:STA SAPTR
LDA SCREENA+1:STA LCOLA+1:ADC #0:STA SAPTR+1
; ╬OTE: LCOLA IS A POINTER TO THE COLUMN THAT
; WILL GO INTO THE RIGHT COL OF SCREEN B
LDA SCREENB:STA SBPTR
LDA SCREENB+1:STA SBPTR+1
LDA #0:STA ROWCOUNT
;
; REPEAT UNTIL 25 ROWS DONE
;
DOROW = *
LDX #0 ;COLUMN COUNTER
;
; REPEAT UNTIL 40 COL DONE
;
- LDY #7
- LDA (SAPTR),Y
STA (SBPTR),Y
DEY:BPL - ;MOVE 8 BYTES
JSR ADD8 ;ADD 8 TO POINTERS
INX ;COLUMN COUNT
CPX #39
BNE -- ;UNTIL 39 COL DONE
LDY #7 ;NOW DO THE LEFT COL
- LDA (LCOLA),Y
STA (SBPTR),Y ;INTO RIGHT COL OF B
DEY:BPL -
; ╬OW SAPTR POINTS TO THE FIRST COL OF
; THE NEXT ROW, SO SAVE IT IN LCOLA
LDA SAPTR:STA LCOLA
LDA SAPTR+1:STA LCOLA+1
JSR ADD8 ;AND ADD 8 TO PTRS AGAIN
;
INC ROWCOUNT
LDX ROWCOUNT
CPX #25 ;CHECK FOR 25 DONE
BNE DOROW ;AND DO NEXT IF NOT DONE
;
; ╘HE BITMAP HAS NOW BEEN MOVED. ╬OW MOVE
; THE COLOR ARRAY. ├OLOR ARRAY IS AT
; SCREEN LOCATION -$2000 +$0800
;
LDA SCREENA+1:AND #$C0:ORA #$08
STA SAPTR+1
STA LCOLA+1
LDA #1:STA SAPTR
LDA #0:STA SBPTR
STA LCOLA
LDA SCREENB+1:AND #$C0:ORA #$08
STA SBPTR+1
; ╞OR THIS, .┘ IS COL COUNT, .╪ IS ROW
;
LDX #0
- LDY #0 ;REPEAT UNTIL 25 ROWS
- LDA (SAPTR),Y ;REPEAT UNTIL 40 COLUMNS
STA (SBPTR),Y
INY
CPY #39
BNE -
LDY #0
LDA (LCOLA),Y
LDY #39
STA (SBPTR),Y
JSR ADD40
LDA SAPTR:AND #$FE:STA LCOLA ;GET RID OF THE +1
LDA SAPTR+1:STA LCOLA+1
INX
CPX #25
BNE --
;
; ┴LL DONE.
;
PLA:STA LCOLA:PLA:STA LCOLA+1
; (RESTORES ┬┴╙╔├ WORK AREA)
; ╘EST CODE...
.IF DEBUG
LDA WORK:STA WORK+1 ;SAVE ╔╥╤ COUNTER
LDA #0:STA WORK ;AND RESET IT.
.IFE
;
RTS
;
; ADD8: ADDS 8 TO SAPTR AND SBPTR.
; ├ALLED 40 TIMES FOR EACH ROW.
ADD8 = *
CLC
LDA SAPTR
ADC #8
STA SAPTR
BCC +
INC SAPTR+1
CLC
+ LDA SBPTR
ADC #8
STA SBPTR
BCC +
INC SBPTR+1
+ RTS
;
; ADD40: ADDS 40 TO SAPTR AND SBPTR.
; ├ALLED ONCE FOR EACH ROW.
ADD40 = *
CLC
LDA SAPTR
ADC #40
STA SAPTR
BCC +
INC SAPTR+1
CLC
+ LDA SBPTR
ADC #40
STA SBPTR
BCC +
INC SBPTR+1
+ RTS
.DIS
;
.END